package learn.emp02.ex35;

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int start = (int) Math.pow(10, N - 1);
        int end = (int) Math.pow(10, N);
        for (int num = start; num < end; num++) {
            if (isNarcissistic(num, N)) {
                System.out.println(num);
            }
        }
    }
    private static boolean isNarcissistic(int num, int power) {
        int original = num;
        int sum = 0;

        while (num > 0) {
            int digit = num % 10;
            sum += Math.pow(digit, power);
            num /= 10;
        }
        return sum == original;
    }
}
